package com.sun.dream.fish.session;

/**
 * Description:
 * Created By ljl on 2023/12/05.
 */
public class DsfThreadLocalHelper {

    private static final ThreadLocal<DSFSession> THREAD_LOCAL = new ThreadLocal<>();

    private DsfThreadLocalHelper() {
    }

    public static final SessionParameters getSessionParameters() {
        return getDSFSession().getSessionParameters();
    }

    public static DSFSession getDSFSession() {
        DSFSession dsfSession = THREAD_LOCAL.get();
        if (null == dsfSession) {
            dsfSession = new DSFSession();
            THREAD_LOCAL.set(dsfSession);
        }
        return dsfSession;
    }

    public void addError(String error) {
        getDSFSession().addError(error);
    }

    public static final void clear() {
        THREAD_LOCAL.remove();
    }
}
